#include<algorithm>
#include<map>
#include"./DeviceHelper.hpp"
#include"../Framework/UnitConvert.hpp"


namespace MMF
{



    uint64_t MMFDeviceHelper::CalcBufferSize(double iqRate)
    {
        const std::map<unsigned long long, unsigned long long> IQ_RATES = {
			{10_MHZ,	128_KB},
			{20_MHZ,	256_KB},
			{50_MHZ,	512_KB},
			{100_MHZ,	1_MB},
			{500_MHZ,	2_MB},
			{1.25_GHZ,	4_MB},
		};

		auto samples = (unsigned long long)IQ_RATES.cbegin()->second;
		std::for_each(IQ_RATES.cbegin(), IQ_RATES.cend(), [iqRate, &samples](const auto& val) {
		if (iqRate >= val.first)
			samples = (unsigned long long)val.second;
		});

        return samples;
    }
}